.TH std::basic_stringbuf::operator= 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::basic_stringbuf::operator= \- std::basic_stringbuf::operator=

.SH Synopsis
   std::basic_stringbuf& operator=( std::basic_stringbuf&& rhs );     \fB(1)\fP \fI(since C++11)\fP
   std::basic_stringbuf& operator=( const std::basic_stringbuf& rhs ) \fB(2)\fP
   = delete;

   1) Move assignment operator: Moves the contents of rhs into *this. After the move,
   *this has the associated string, the open mode, the locale, and all other state
   formerly held by rhs. The six pointers of std::basic_streambuf in *this are
   guaranteed to be different from the corresponding pointers in the moved-from rhs
   unless null.
   2) The copy assignment operator is deleted; basic_stringbuf is not CopyAssignable.

.SH Parameters

   rhs - another basic_stringbuf that will be moved from

.SH Return value

   *this

.SH Example


// Run this code

 #include <iostream>
 #include <sstream>
 #include <string>

 int main()
 {
     std::istringstream one("one");
     std::ostringstream two("two");

     std::cout << "Before move, one = \\"" << one.str() << '"'
               << " two = \\"" << two.str() << "\\"\\n";

     *one.rdbuf() = std::move(*two.rdbuf());

     std::cout << "After move, one = \\"" << one.str() << '"'
               << " two = \\"" << two.str() << "\\"\\n";
 }

.SH Output:

 Before move, one = "one" two = "two"
 After move, one = "two" two = ""

.SH See also

   constructor   constructs a basic_stringbuf object
                 \fI(public member function)\fP
